package com.example.demo.Redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisUtil {
    private static JedisPool jedisPool;

    static {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();

        String host = "172.20.10.5";
        int port = 6379;

        jedisPool = new JedisPool(jedisPoolConfig,host,port);
    }

    //启动连接池
    public static Jedis getJedsi(){
        Jedis jedis = jedisPool.getResource();
        jedis.auth("Liupeng8");
        return jedis;
    }
    //关闭
    public static void close(Jedis jedis){
        jedis.close();
    }

}
